﻿@model ORM.ViewModels.Account.UpdateUserProfileViewModel
@using ORM.Framework.Security;
@using ORM.Common;
@using ORM.Helpers
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<table class="contentBox" width="100%">
    <tr>
        <th class="boxTitle">
            Thay Đổi Thông Tin Cá Nhân<span id="questionNavigator"></span>
        </th>
    </tr>
    <tr>
        <td style="vertical-align: top;">
            @using (Html.BeginForm("EditUserInformation", "Account", FormMethod.Post, new { enctype = "multipart/form-data", @id = "user-edit-form" }))
            {
                @Html.ValidationSummary(true)

            
                <div class="editor-label">
                    Giới tính
                </div>
                <div class="editor-field">
                    @{
                Dictionary<string, string> sex = new Dictionary<string, string>();
                sex.Add("", "");
                sex.Add("Nam", "Nam");
                sex.Add("Nữ", "Nữ");
                SelectList listSex = new SelectList(sex, "value", "key", "");
                    }
                    @Html.DropDownListFor(m => m.User.Sex, listSex, new { @style = "width:205px" })
                    @Html.ValidationMessageFor(m => m.User.Sex)
                </div>
                <div class="editor-label">
                    Ngày sinh
                </div>
                <div class="editor-field">
                    @Html.TextBoxFor(model => model.User.Birthday, new { @id = "datePicker", @style = "width:200px;" })
                    @Html.ValidationMessageFor(model => model.User.Birthday)
                </div>
                <div class="editor-label">
                    Giới thiệu về bản thân
                </div>
                <div class="editor-field">
                    @Html.TextAreaFor(m => m.User.Hobbies, new { @rows = "10", @cols = "60" })
                    @Html.ValidationMessageFor(m => m.User.Hobbies)
                </div>
                <div class="editor-label">
                    Thay đổi hình đại diện
                </div>
                <div class="editor-field">
                    <input id="edit-picture-upload" type="file" style="height: 25px" name="File" />
                </div>
      
                <br />
                <button type="submit" style="height: 25px; width: 150px">
                    Cập Nhật Thông Tin</button>
                <button type="button" style="height: 25px; width: 75px" onclick="MyFc()">
                    Huỷ
                </button>
                <br />
                <br />
                <script type="text/javascript">
           if($("#datePicker").val() != "") {
               var d = new Date($("#datePicker").val());
                var date = d.getDate();
            var month = d.getMonth() + 1; 
    var year = d.getFullYear();
               var dateToDisplay = month + "/" + date + "/" + year;
               $("#datePicker").val(dateToDisplay);
           }
           $("#datePicker").datepicker(
               {
                   changeMonth: true,
                   changeYear: true,
                   showOtherMonths: true,
                   selectOtherMonths: true,
                   yearRange: "1905:2012",
               }
           );
           function MyFc() {
               window.location = "/Account/Profile";
           }
                </script>
                if (ViewBag.UploadImageError != null)
                {
                <script type="text/javascript">
                    if (ViewBag.UploadImageError != null) {
                        alert(ViewBag.UploadImageError);
                    }
                </script>
                }
                if (ViewBag.EMessage == "2")
                {
                <script type="text/javascript">
                    $(document.createElement('div'))
        .attr({ title: 'Fixtech.vn', 'class': 'alert' })
        .html("Cập nhật thông tin thành công!")
        .dialog({
            buttons: { OK: function () {
                window.location = "/Account/Profile";
                 $(this).dialog('close');
            } },
         close: function () {
             window.location = "/Account/Profile";
                 $(this).remove();
            },
            draggable: true,
            modal: true,
            resizable: false,
            width: 500,
            open: function (event, ui) {
                $("button").blur();
            }
        });
                    
                </script>                     
                }
            }
        </td>
    </tr>
</table>
